<?php global $has_permit; ?>
<div class="std_header auto_height">
    <div class="left">
        <strong><?php echo $module['title']; ?></strong>
    </div>
    <div class="right">
        <button class="gray_btn" onclick="admin_site_zone.create_new()"><span>Thêm mới</span></button>
    </div>
</div>
<div class="db_left bl">
    <?php $this->load->view('layouts/side_block'); ?>
</div>
<div class="db_right bl">
    <?php if ($has_permit) :?>
    <div id="zone_management">
        <div id="tab_store" class="tab_container">
            <ul>
                <li id="active_tab_list"><a href="#tab_list"><span>Danh sách</span></a></li>
                <li id="active_tab_edit"><a href="#tab_edit"><span>Thông tin</span></a></li>
            </ul>
            <div id="tab_list">
                <?php if (count($collection) != 0) : ?>
                <?php $this->load->view('site/zone/message'); ?>
                <form action="<?php echo site_url('admin/site/zone/index', true); ?>" method="post" id="frm_zone_gridview">
                    <div class="block">
                        <table class="gridview" width="100%" cellpadding="0" cellspacing="0" border="0">
                            <thead>
                            <tr>
                                <td><b>ID</b></td>
                                <td><b>Tiêu đề</b></td>
                                <td><b>Mô tả</b></td>
                                <td><b>Xử lý</b></td>
                            </tr>
                            </thead>
                            <tbody>
                                <?php foreach ($collection as $zone) : ?>
                            <tr>
                                <input type="hidden" value="" class="edit_url" />
                                <td width="30px" valign="top">
                                    <?php echo $zone->id; ?>
                                </td>
                                <td valign="top">
                                    <p><a class="ajax_link" data="{id:<?php echo $zone->id; ?>}" selector="#tab_edit" item="#active_tab_edit a" href="<?php echo site_url('admin/site/zone/ajax_edit/id/' . $zone->id, true); ?>"><strong><?php echo $zone->code; ?></strong></a></p>
                                    <?php echo $zone->heading; ?>
                                </td>
                                <td valign="top">
                                    <?php echo (empty($zone->description)) ? 'Empty' : $zone->description; ?>
                                </td>
                                <td valign="top">
                                    <p><a class="ajax_link icon icon_edit" data="{id:<?php echo $zone->id; ?>}" selector="#tab_edit" item="#active_tab_edit a" href="<?php echo site_url('admin/site/zone/ajax_edit/id/' . $zone->id, true); ?>"></a> <a class="icon icon_delete" href="<?php echo site_url('admin/site/zone/delete/id/' . $zone->id, true); ?>" onclick="return confirm('Bạn muốn xóa vùng hiển thị này?')"></a></p>
                                </td>
                            </tr>
                                <?php endforeach; ?>
                            </tbody>
                            <tfoot>

                            </tfoot>
                        </table>
                    </div>
                </form>
                <?php else : ?>
                <div class="error_message corner">Không tìm thấy vùng nào</div>
                <?php endif; ?>
            </div>
            <div id="tab_edit">
                <form id="frm_zone_edit" method="POST" action="<?php echo $save_action; ?>">
                    <div class="clearfix auto_height mb_10">
                        <button class="gray_btn active_item" type="button" item="#active_tab_list a"><span>Về danh sách</span></button>
                        <button class="gray_btn" type="submit"><span>Lưu lại</span></button>
                        <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    </div>
                    <div class="form_block">
                        <div class="block_header">
                            Thông tin căn bản
                        </div>
                        <div class="block_content">
                            <table cellpadding="0px" cellspacing="0px">
                                <?php if (isset($collection) && $collection && count($collection) > 0) :?>
                                <tr>
                                    <td class="frm_label">Vùng bao(*)</td>
                                    <td class="frm_field">
                                        <select class="std_input" name="data[parent_id]">
                                            <option value="0">Là vùng chính</option>
                                            <?php foreach ($collection as $parent) :?>
                                            <option value="<?php echo $parent->id; ?>"><?php echo $parent->heading; ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </td>
                                </tr>
                                <?php endif; ?>
                                <tr>
                                    <td class="frm_label">Kiểu(*)</td>
                                    <td class="frm_field">
                                        <select name="data[type]" style="width: 180px">
                                            <option>Chọn kiểu hiển thị</option>
                                            <?php foreach ($this->site_zone_model->get_types() as $type => $label) :?>
                                            <option value="<?php echo $type; ?>"><?php echo $label; ?></option>
                                            <?php endforeach; ?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Tiêu đề(*)</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input required" name="data[heading]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Mô tả</td>
                                    <td class="frm_field">
                                        <textarea name="data[description]"></textarea>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Mã</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input" name="data[code]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Chiều dài</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input required" name="data[width]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Chiều rộng</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input required" name="data[height]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Lớp CSS</td>
                                    <td class="frm_field">
                                        <input type="text" class="std_input" name="data[class]" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="frm_label">Ẩn(*)</td>
                                    <td class="frm_field">
                                        <select id="zone_hidden" class="std_input" name="data[hidden]">
                                            <option>Chọn chế độ</option>
                                            <option value="0">Không</option>
                                            <option value="1">Có</option>
                                        </select>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="clearfix auto_height">
                        <button class="gray_btn active_item" type="button" item="#active_tab_list a"><span>Về danh sách</span></button>
                        <button class="gray_btn" type="submit"><span>Lưu lại</span></button>
                        <button class="gray_btn" type="reset"><span>Nhập lại</span></button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <?php else :?>
    <?php $this->load->view('layouts/restricted'); ?>
    <?php endif; ?>
</div>
<div class="clearfix"></div>
<script type="text/javascript">
    $("#frm_zone_edit").validate();
</script>
<script type="text/javascript" src="<?php echo BASE_URL; ?>js/admin/site/zone/function.js"></script>